package com.polaris.live.popup.party

import android.content.Context
import com.blankj.utilcode.util.StringUtils
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.CenterPopupView
import com.polaris.live.R
import com.polaris.live.common.ext.setOnSingleClickListener
import com.polaris.live.databinding.PopupRemoveMemberBinding
import com.polaris.live.im.sfs.bean.live.ext.UserBasicVo
import com.polaris.live.translation.R.string
import com.polaris.live.widget.avatar.FrameImageUtils

/**
 * RemoveMemberPopup 移除成员提示
 *
 * @author Created by 天晴 on 2024/3/8 19:18
 * @since 1.0.0
 **/
class RemoveMemberPopup(
    context: Context,
    private val userBasicVo: UserBasicVo,
    private val onOk: () -> Unit,
) : CenterPopupView(context) {

    private lateinit var mBinding: PopupRemoveMemberBinding
    override fun getImplLayoutId(): Int {
        return R.layout.popup_remove_member
    }

    override fun onCreate() {
        super.onCreate()
        mBinding = PopupRemoveMemberBinding.bind(popupImplView)
        mBinding.cancel.setOnSingleClickListener {
            dismiss()
        }
        mBinding.cancel.setOnSingleClickListener {
            dismiss()
        }
        mBinding.confirm.setOnSingleClickListener {
            dismiss()
            onOk.invoke()
        }

        mBinding.apply {
            tvMessage.text = StringUtils.getString(string.kick_member_tips)

            avFv.setFrameImage(FrameImageUtils.urlToFrameImageBean(userBasicVo.avatarFrame))
            avatar.setImageUrl(userBasicVo.avatar, userBasicVo.userId)

            tvRoomName.text = userBasicVo.nickname
            idView.setId(userBasicVo)
            languageView.setLanguage(userBasicVo.secondLanguage)
            country.setCountry(userBasicVo.country)
            ageSex.setSexAndAge(userBasicVo.sex, userBasicVo.birthday)
            vipView.setVipLevel(userBasicVo.vipLevel)
            level1.setRichsLevel(userBasicVo.richs)
            level2.setCharmsLevel(userBasicVo.charms)
            llFlag.setLabel(userBasicVo.label)
        }
    }

    companion object {

        fun show(
            context: Context,
            userBasicVo: UserBasicVo,
            onOk: () -> Unit,
        ) {
            XPopup.Builder(context)
                .isViewMode(false)
                .hasShadowBg(true)
                .moveUpToKeyboard(false)
                .isDestroyOnDismiss(true)
                .asCustom(RemoveMemberPopup(context, userBasicVo, onOk))
                .show()
        }
    }
}